package indi.zhifa.recipe.bailan.framework.mysql.entity.po;

import com.alibaba.fastjson2.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;

/**
 * @Copyright: Copyright (c) 2018-2025    All rights reserved.
 * @author: bixuejun(bxjgood @ 163.com)
 * @date: 2018/4/27 10:46
 * @Description: 统一定义id的BaseEntity基类.基类统一定义id的属性名称、数据类型.子类可重载getId()函数.
 */
@Data
public class BaseEntity extends SysBaseEntity{

    @JSONField(serialize = false, deserialize = false)
    @TableField(fill = FieldFill.INSERT)
    @Schema(title = "创建用户Id")
    protected Long createBy;
    @JSONField(serialize = false, deserialize = false)
    @TableField(fill = FieldFill.INSERT)
    @Schema(title = "创建用户昵称")
    protected String createName;
    @JSONField(serialize = false, deserialize = false)
    @TableField(fill = FieldFill.INSERT)
    @Schema(title = "创建者Ip")
    protected String createIp;
    @JSONField(serialize = false, deserialize = false)
    @TableField(fill = FieldFill.UPDATE)
    @Schema(title = "修改用户Id")
    protected Long modifyBy;
    @JSONField(serialize = false, deserialize = false)
    @TableField(fill = FieldFill.UPDATE)
    @Schema(title = "修改用户昵称")
    protected String modifyName;
    @JSONField(serialize = false, deserialize = false)
    @TableField(fill = FieldFill.UPDATE)
    @Schema(title = "创建者Ip")
    protected String modifyIp;
    @JSONField(serialize = false, deserialize = false)
    @TableLogic(delval = "id",value = "0")
    @Schema(title = "是否删除")
    protected Long del;

    @Override
    public void createInit() {
        super.createInit();
        // 靠全局配置填充
        createBy = null;
        createName = null;
        createIp = null;

        modifyBy = null;
        modifyName = null;
        modifyIp = null;
        version = 0;
        del = 0L;
    }

    @Override
    public void updateInit() {
        super.updateInit();
        modifyBy = null;
        modifyName = null;
        modifyIp = null;
    }

}
